<template>
	<view>
		<!-- 一般报销审核 -->
		<view class="head_tb" v-if="sgshow">
			<u-tabs :activeStyle="{
						 fontSize:'32rpx',
						 color: '#007aff'
			         }" :inactiveStyle="{
						 fontSize:'30rpx'
			         }" :scrollable='false' :lineWidth='30' itemStyle='height:90rpx;width:25%' :list="list1"
				@click="checkbtn"></u-tabs>
		</view>
			
		<!-- 基本信息 -->
		<view class="msp">
			<CellChild :addlist='addlist' title='基本信息' :rows='rows' :fileNo = 'fileNo' id='add_one'>
			</CellChild>
		</view>
		<!-- 丧葬慰问单 -->
		<CellChild v-if="dieshow" :addlist='salutelist' title='慰问人信息' :rows='rows' id='add_die'>
			
		</CellChild>
		
		<!-- 报销明细 -->
		<view class="formcard" id="add_three">
			<view class="bodtitle">
				<p><b>报销明细</b></p>
			</view>
			<view v-for="(item,index) in arrcell" :key="index">
				<Expandlist :cellshows='cellshow' :celllist='celllist1'  :arrcell='item'  :title='item.budgetNo'>
					<template #text>
						<p class='solts'><label class="solts_label"><label style='font-size: 18rpx;color: #999999;'>报销</label>￥</label><span class="solts_span" v-money>{{arrcell[index].costReimAmt}}</span></p>
					</template>
				</Expandlist>
			</view>
		</view>
		
		<!-- 党工验收信息 -->
		<view class="formcard" id="add_dg"  v-if="uzishow">
			<view class="bodtitle">
				<p><b>验收信息<label style="color: red;"> *</label></b></p>
			</view>
			
			<Expandlist :cellshows='cellshow' :celllist='uzilist' :arrcell = 'dgarrcell'  :title='dgarrcell.serverDesc'>
				<template #text>
				</template>
			</Expandlist>
		</view>
		
		<!-- 收款方信息 -->
		<view class="formcard" id="add_two">
			<view class="bodtitle">
				<p><b>收款方信息</b></p>
			</view>
			<view v-for="(item,index) in banklist" :key="index">
				<Expandlist :cellshows='cellshow' :arrcell='item' :celllist='celllist' :title='item.payee'>
					<template #text>
						<p class='solts'><label class="solts_label"><label style='font-size: 18rpx;color: #999999;'>支付</label>￥</label><span class="solts_span" v-money>{{item.payAmt}}</span></p>
					</template>
				</Expandlist>
			</view>	
		</view>
		
		
		
		<!-- 报销金额 -->
		<view class="msp">
			<CellChild :addlist='addlistx' title='报销金额' :rows='rows' >
			</CellChild>
		</view>
		
		<!-- 收款方信息 -->
		<view class="formcard" >
			<view class="bodtitle">
				<p><b>收款方信息</b></p>
			</view>
				<Expandlist :cellshows='cellshow' :arrcell='rows.bankList'  :celllist='celllist3'   :title='rows.payee'>
					<template #text>
						<p class='solts'><label class="solts_label">￥</label><span class="solts_span" v-money>{{rows.payAmt}}</span></p>
					</template>
				</Expandlist>
		</view>
		
		<!-- 借款信息 -->
		<view class="formcard" id="add_four" v-if="jkshow">
			<view class="bodtitle">
				<p><b>借款信息</b></p>
			</view>
				<Expandlist :cellshows='cellshow' :arrcell='rows'  :celllist='celllist2'   :title='rows.borrowNo'>
					<template #text>
						<p class='solts'><label class="solts_label">￥</label><span class="solts_span" v-money>{{rows.approveAmt}}</span></p>
					</template>
				</Expandlist>
		</view>
		
		<!-- 申购明细 -->
		<view class="formcard">
			<view class="bodtitle">
				<p><b>申购明细</b></p>
			</view>
				<Expandlist :cellshows='cellshow' :arrcell='applyList'  :celllist='celllist5'   :title='rows.borrowNo'>
					
				</Expandlist>
		</view>
	</view>
</template>

<script>
	export default {
		components:{
		},
		data() {
			return {
				//申购单
				list1: [
					{name: '基本信息',},
					{name: '收款方'},
					{name: '费用明细'},
					{name: '借款信息'},
				],
				//党工单
				list2: [{
						name: '基本信息',
					},
					{
						name: '验收信息'
					},
					{
						name: '收款方'
					},
					{
						name: '费用明细'
					},
				],
				//死亡慰问单
				list3: [
					{name: '基本信息',},
					{name: '慰问人'},
					{name: '收款方'},
					{name: '费用明细'},
				],
				cellshow:true,
				sgshow:false,
				//申购单类型
				addlist: [{
						tit: '报销单号',
						val: 'expAccountNo'
					},
					{
						tit: '申请人',
						val: 'userDesc'
					},
					{
						tit: '科室',
						val: 'deptNm'
					},
					{
						tit: '报销类型',
						val: 'reimType'
					},
					{
						tit: '申购单号',
						val: 'relationBill'
					},
					{
						tit: '申请单位编号',
						val: 'deptId'
					},
					{
						tit: '申请单位名称',
						val: 'deptNm'
					},
					{
						tit: '费用承担科室',
						val: 'subdeptNm'
					},
					
					{
						tit: '单据日期',
						val: 'billDate'
					},
					{
						tit: '纸张单据张数',
						val: 'paperConut'
					},
					{
						tit: '币种',
						val: 'coinKind'
					},
					{
						tit: '记账日期',
						val: 'payDate'
					},
					
					{
						tit: 'QAD记账状态',
						val: 'payStatus'
					},
					// {
					// 	tit: '报销结算方式',
					// 	val: '',
					// },
					{
						tit: '是否有合同',
						val: 'ifContract',
					},{
						tit: '合同编号',
						val: 'contractNo'
					},
					{
						tit: '合同名称',
						val: 'contractNm'
					},
					{
						tit: '资金支付计划款项',
						val: 'planCapital'
					},
					// {
					// 	tit: '冲账确认',
					// 	val: ''
					// },
					// {
					// 	tit: '付款确认',
					// 	val: ''
					// },
					{
						tit: '报销说明',
						val: 'reasons'
					},
				],		
				//党工团类型
				addlist2: [{
						tit: '报销单号',
						val: 'expAccountNo'
					},
					{
						tit: '申请人',
						val: 'userDesc'
					},
					{
						tit: '申请单位',
						val: 'deptNm'
					},
					{
						tit: '报销类型',
						val: 'reimType'
					},
					{
						tit: '申购单号',
						val: 'relationBill'
					},
					{
						tit: '申请单位编号',
						val: 'deptId'
					},
					{
						tit: '申请单位名称',
						val: 'deptNm'
					},
					{
						tit: '费用承担科室',
						val: 'subdeptNm'
					},
					
					{
						tit: '单据日期',
						val: 'billDate'
					},
					{
						tit: '纸张单据张数',
						val: 'paperConut'
					},
					{
						tit: '币种',
						val: 'coinKind'
					},
					{
						tit: '记账日期',
						val: 'payDate'
					},
					
					{
						tit: 'QAD记账状态',
						val: 'payStatus'
					},
					{
						tit: '报销结算方式',
						val: '',
					},
					{
						tit: '是否有合同',
						val: 'ifContract',
					},{
						tit: '合同编号',
						val: 'contractNo'
					},
					{
						tit: '合同名称',
						val: 'contractNm'
					},
					{
						tit: '资金支付计划款项',
						val: 'planCapital'
					},
					// {
					// 	tit: '冲账确认',
					// 	val: ''
					// },
					// {
					// 	tit: '付款确认',
					// 	val: ''
					// },
					
					
					
					{
						tit: '报销说明',
						val: 'reasons'
					},
				],	
				uzishow:false,
				// 死亡/生育慰问金
				addlist3: [{
						tit: '报销单号',
						val: 'expAccountNo'
					},
					{
						tit: '申请人',
						val: 'userDesc'
					},
					
					{
						tit: '报销类型',
						val: 'reimType'
					},
					{
						tit: '科室',
						val: ''
					},
					{
						tit: '费用承担科室',
						val: ''
					},
					{
						tit: '单据日期',
						val: 'billDate'
					},
					{
						tit: '纸张单据张数',
						val: 'paperConut'
					},
					{
						tit: '币种',
						val: 'coinKind'
					},
					{
						tit: '发票报销金额合计',
						val: 'invoiceAmt',
						type:'number'
					},
					{
						tit: '审核报销金额合计',
						val: 'auditAmt',
						type:'number'
					},
					{
						tit: '支付金额',
						val: 'payAmt',
						type:'number'
					},
					{
						tit: '记账日期',
						val: 'payDate'
					},
					{
						tit: 'QAD记账状态',
						val: 'payStatus'
					},
					{
						tit: '支付方式',
						val: 'payType'
					},
					
				],	
				addlistx: [{
						tit: '借款金额',
						val: 'borrowAmt',
						type:'number'
					},{
						tit: '发票报销金额合计',
						val: 'invoiceAmt',
						type:'number'
					},
					{
						tit: '审核报销金额合计',
						val: 'auditAmt',
						type:'number'
					},{
						tit: '应还款金额',
						val: 'repayAmt',
						type:'number'
					},{
						tit: '支付金额',
						val: 'payAmt',
						type:'number'
					},{
						tit: '审核进项增值税合计',
						val: 'taxAmountCount',
						type:'number'
					}
				],
				uzilist:[	//物资
					{tit:'应用项目',val:'appProject'},
					{tit:'需要采购执行',val:'ifExecute'},
					{tit:'规格',val:'norms'},
					{tit:'品牌',val:'brand'},
					{tit:'单价',val:'price',type:'number'},
					{tit:'数量',val:'quantity'},
					{tit:'小计',val:'total',type:'number'},
					{tit:'实际单价',val:'actulPrice',type:'number'},
					{tit:'实际数量',val:'actulQuantity'},
					{tit:'实际小计',val:'actulTotal',type:'number'},
					{tit:'评分分值',val:'score'},
					{tit:'评分备注',val:'scoreDesc'},
					{tit:'报销金额',val:'reimAmt',type:'number'},
					{tit:'有无发票',val:'ifInvoice'},
					{tit:'有无双签',val:'twoSign'},
					{tit:'有无项目明细单',val:'ifProjectDetaile'},
					{tit:'有无支付凭证',val:'ifPay'},
					{tit:'有无签收凭证',val:'ifSign'},
					{tit:'备注',val:'remarks'},
				],
				dieshow:false,
				salutelist:[ //死亡抚恤慰问
					{tit:'死亡人姓名',val:'saluteName'},
					{tit:'年龄',val:'saluteAge'},
					{tit:'性别',val:'saluteSex'},
					{tit:'与慰问人关系',val:'saluteRelation'},
					{tit:'死亡时间',val:'saluteTime'},
					{tit:'死亡地点',val:'saluteAddress'},
					{tit:'申请费用类别',val:'costType'},
				],
				bearshow:false,
				bearlist:[ //生育慰问金
					{tit:'慰问者姓名',val:'saluteName'},
					{tit:'年龄',val:'saluteAge'},
					{tit:'性别',val:'saluteSex'},
					{tit:'与慰问人关系',val:'saluteRelation'},
					{tit:'慰问时间',val:'saluteTime'},
					{tit:'慰问地点',val:'saluteAddress'},
					{tit:'慰问原因',val:'costType'},
				],
				celllist:[
					{tit:'收款方类型',val:'payeeType'},
					{tit:'收款方开户银行',val:'payeeBank'},
					{tit:'收款方开户账号',val:'bankcardNo'},
				],
				//费用明细列表
				// celllist1:[
				// 	{tit:'预算号名称',val:'budgetNm'},
				// 	{tit:'申购单号',val:'purchaseOrder'},
				// 	// {tit:'预算金额',val:''},
				// 	// {tit:'剩余可用金额',val:''},
				// 	{tit:'不含税金额',val:'notaxAmt',type:'number'},
				// 	{tit:'税率',val:'taxRate',type:'bfb'},
				// 	{tit:'税额',val:'taxPer',type:'number'},
				// 	{tit:'含税金额',val:'inTaxAmt',type:'number'},
				// 	{tit:'会计科目',val:'costAccount'},
				// 	{tit:'会计科目名称',val:'accountNm'},
				// 	{tit:'财务核报金额',val:'costAuditAmt',type:'number'},
				// 	{tit:'是否最后一次报销',val:'isSublast'},
				// 	{tit:'备注',val:'descs'},
				// ],
				//借款明细明细列表
				celllist1:[
					// {tit:'科室',val:''},
					{tit:'预算年度',val:'budgetYear'},
					{tit:'预算月度',val:'budgetMonth'},
					{tit:'预算号',val:'budgetNo'},
					{tit:'预算号名称',val:'budgetNm'},
					{tit:'会计科目',val:'costAccount'},
					{tit:'会计科目名称',val:'accountNm'},
					{tit:'申购单号',val:'purchaseOrder'},
					{tit:'不含税金额',val:'notaxAmt',type:'number'},
					{tit:'税额',val:'taxPer',type:'number'},
					{tit:'含税金额',val:'inTaxAmt',type:'number'},
					{tit:'报销金额',val:'costReimAmt',type:'number'},
					{tit:'审核不含税金额',val:'costAuditAmt',type:'number'},
					{tit:'审核进项增值税',val:'appTaxAmount',type:'number'},
					{tit:'申请金额',val:'applyAmount',type:'number'},
					{tit:'未报销金额',val:'leftAmount',type:'number'},
					{tit:'进项增值税额',val:'ltaxAmount',type:'number'},
					{tit:'报销不含税金额',val:'noTaxAmount',type:'number'},
					{tit:'预提单号',val:'accruedBillNo'},
					{tit:'预提金额',val:'accruedAmount',type:'number'},
					{tit:'是否最后一次报销',val:'isSublast'}, //1是0否
					{tit:'备注',val:'descs',},
				],
				jkshow:true, //借款明细
				
				//收款方信息
				celllist3:[
					{tit:'收款方类型',val:'payeeType'},
					{tit:'收款方',val:'payee'},
					{tit:'收款方开户银行名称',val:'payeeBank'},
					{tit:'收款方银行账号',val:'bankcardNo'},
					{tit:'支付金额',val:'payAmt',type:'number'},
				],
				//借款明细列表				
				celllist2:[
					{tit:'行项目',val:'borrowId'},
					{tit:'借款事由',val:'reasons'},
					{tit:'借款类型',val:'payeeType'},
				],
				//申购明细
				celllist5:[
					{tit:'控制方式',val:'controlMode'},
					{tit:'品类金额合计',val:'categoryTotalMoney',type:'number'},
					{tit:'是否超过预算',val:'isExceed'},//0 不是 1是
					{tit:'超过预算原因',val:'exceedReason'},
					{tit:'备注',val:'remarks'},
					{tit:'是否需要采购执行',val:'sPurchaseExecute'}, //0 不是 1是
					{tit:'品名/规格/内容型号',val:'categoryName'},
					{tit:'品牌',val:'brand'},
					{tit:'单价',val:'unitPrice',type:'number'},
					{tit:'审核金额',val:'auditMoney',type:'number'},
					{tit:'数量',val:'number'},
					{tit:'供应商',val:'supplier'},
					{tit:'正常纳期时间',val:'normalDeliveryTime'},
					{tit:'交货时间',val:'deliveryTime'},
					{tit:'前期损耗',val:'earlyConsume'},
				],
				rows:[],
				//费用明细列表
				arrcell:[],
				//借款明细列表
				arrcell1:[],
				// 党工验收信息
				dgarrcell:[],
				// 收款人信息
				banklist:[],
				//申购明细
				applyList:[],
				fileNo:[]//附件消息
			}
		},
		onLoad() {
			 //获取流程页面的流程上下文[实用的流程信息从这里获取]
			  let billNo= window.parent.myvm.wfContext.BusinessKey;
			  this.fileNo = window.parent.myvm.wfContext.BusinessKey;
			  this.getlist(billNo)
		},
		mounted() {
			var that = this;
			window.myvm = that;
			window.$urlFormVue = that;
		},
		methods: {
			//审批和驳回-工作流点击"提交"时触发此函数，返回:空字符串:工作流继续提交，返回"具体错误信息":工作流不提交
			rejectWorkflow(btnDef) {
				return "";
			},
			//作废-工作流点击"作废"时触发此函数，返回:空字符串:工作流继续提交，返回"具体错误信息":工作流不提交
			//content为作废意见
			invalidWorkflow(content) {
				return "";
			},
			//转办-工作流点击"确认转办"时触发此函数，返回:空字符串:工作流继续提交，返回"具体错误信息":工作流不提交
			//opinion:转办意见
			referredWorkflow(opinion) {
				return "";
			},
			//校验-工作流点击"提交"时触校验函数，返回:true校验通过，false校验不通过；
			//也可以返回具体的错误信息：空字符串，校验通过，返回具体错误信息校验不通过，同时弹出具体的错误信息。
			validateWorkflowForm(btnDef,callback) {
				callback("");
			},
			//提交单据
			sendWorkflow(btnDef, callback) {
				callback("");
			},
			getlist(expAccountNo){
				let _this = this
				let params = {
					expAccountNo
				}
				_this.$lyRequest.get('/gateway/reim/mp/dbsap/reim/expAccount/show.do',
					params
				).then((result)=>{
					if(result.success){
							this.rows = result.data.rows
							this.arrcell = result.data.rows.expAccountCostList  //费用明细
							this.dgarrcell = result.data.rows.checkEntityList
							this.banklist = result.data.rows.bankList  //收款方信息
							this.applyList = result.data.rows.applyList
							this.changelist()
							
					}else{
						console.log(result.data.msg)
					}
				})
			},
			changelist(){
				// let _this = this
				// let params = {
				// 	relationBill:this.rows.relationBill
				// }
				// _this.$lyRequest.get('/gateway/reim/mp/dbsap/reim/borrowm/selectPage.do',
				// 	params
				// ).then((result)=>{
				// 	if(result.success){
				// 			console.log(result)
							
				// 	}else{
				// 		console.log(result.data.msg)
				// 	}
				// })
				this.checkform()
				//是否签合同
				switch (this.rows.ifContract){
					case '1':
						this.rows.ifContract = '是'
						break;
					case '0':
						this.rows.ifContract =' 否'
						break;
				}
				//记账状态
				switch (this.rows.payStatus){
					case '1':
						this.rows.payStatus = '已记账'
						break;
					case '0':
						this.rows.payStatus =' 未记账'
						break;
				}

				// 死亡慰问 申请费用类别判断
				switch (this.rows.costType){
					case '1':
						this.rows.costType = '慰问金'
						break;
					case '2':
						this.rows.costType =' 抚恤金'
						break;
				}

				for(let i = 0;i<this.arrcell.length;i++){
					//是否最后一次借款
					if(this.arrcell[i].isSublast == 0){
						this.arrcell[i].isSublast = '否'
					}else{
						this.arrcell[i].isSublast = '是'
					}
				}
				
				//判断收款方类型
				for(let i = 0;i<this.banklist.length;i++){
					//是否最后一次借款
					if(this.banklist[i].payeeType == 0){
						this.banklist[i].payeeType = '员工'
					}else if(this.banklist[i].payeeType == 1){
						this.banklist[i].payeeType = '供应商'
					}else if(this.banklist[i].payeeType == 2){
						this.banklist[i].payeeType = '供应商'
					}
				}
				console.log(this.banklist.payeeType)
				
				if(this.rows.planCapital == true){
					this.rows.planCapital = '是'
				}else {
					this.rows.planCapital = '否'
				}
			},
			
			//判断单据类型
			checkform(){
				switch (this.rows.reimType){
					case '1' :
						this.sgshow = true
						this.rows.reimType = '申购单'
						break;
					case '2' :
						this.rows.reimType = '党工团'
						this.addlist = this.addlist2
						this.uzishow = true
						this.list1 = this.list2
						break;
					case '3' :
						this.sgshow = true
						this.rows.reimType = '水电气'
						break;
					case '4' :
						this.dieshow = true
						this.rows.reimType = '丧葬慰问费'
						this.addlist = this.addlist3
						this.jkshow = false
						this.list1 = this.list3
						break;
					case '5' :
						this.sgshow = true
						this.rows.reimType = '生育住院慰问费'
						this.addlist = this.addlist3
						this.dieshow = true
						this.list1 = this.list3
						this.jkshow = false
						break;
					case '6' :
						this.sgshow = true
						this.rows.reimType = '探亲路费'
						break;
					case '7' :
						this.sgshow = true
						this.rows.reimType = '文体'
						break;
					case '8' :
						this.sgshow = true
						this.rows.reimType = '其他（税/支援/提成/派驻等）'
						break;
				}
			},
			checkbtn(item) { //切换tabs
				if(this.sgshow==true){
					if (item.index === 0) {
						this.commonApi.goAnchor('add_one')
					} else if (item.index === 1) {
						this.commonApi.goAnchor('add_two')
					} else if (item.index === 2) {
						this.commonApi.goAnchor('add_three')
					}else if (item.index === 3) {
						this.commonApi.goAnchor('add_four')
					}
				}else if(this.uzishow==true){
					if (item.index === 0) {
						this.commonApi.goAnchor('add_one')
					} else if (item.index === 1) {
						this.commonApi.goAnchor('add_dg')
					} else if (item.index === 2) {
						this.commonApi.goAnchor('add_two')
					}else if (item.index === 3) {
						this.commonApi.goAnchor('add_three')
					}
				}else if(this.dieshow == true){
					if (item.index === 0) {
						this.commonApi.goAnchor('add_one')
					} else if (item.index === 1) {
						this.commonApi.goAnchor('add_die')
					} else if (item.index === 2) {
						this.commonApi.goAnchor('add_two')
					}else if (item.index === 3) {
						this.commonApi.goAnchor('add_three')
					}
				}	
			},
		}
	}
</script>

<style scoped lang="scss">
view{
	font-family: pf;
}
.bodcolor{
		span{
			color:#ff6400;
			font-size: 36rpx;
			padding-right: 20rpx;
		}
		label{
			color: #ff6400;
		}
	}
	.bottom_setup {
		width: 100%;
		height: 160rpx;
		background-color: white;
		margin-top: 20rpx;
		padding: 35rpx 0;
		box-sizing: border-box;
		box-shadow: 5px -10rpx 5px 0px rgba(225, 225, 225, .4), ;
	
		.bottom_white1 {
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-between;
			height: 100rpx;
	
			.custom-styles {
				padding: 20rpx 30rpx;
				width: 300rpx;
				height: 100rpx;
			}
	
			.custom-style {
				padding: 20rpx 30rpx;
				width: 300rpx;
				height: 100rpx;
				background-color: #007aff;
			}
		}
	}
</style>
